//
//  RoadVC.m
//  TT
//
//  Created by Lenny on 16/4/15.
//  Copyright © 2016年 Lenny. All rights reserved.
//

#import "RoadVC.h"

//Views
#import "RoadDownV.h"
#import "RoadSlideV.h"
#import "RoadTopV.h"
#import "ChatV.h"

//VCs
#import "RoadLineVC.h"

@interface RoadVC ()
{
    CGFloat _downViewHigh;
    CGFloat _topViewHgih;
    CGFloat _slideHigh;
}

@property(nonatomic,strong)ChatV *chatV;

@end

@implementation RoadVC

#pragma mark - life cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = WL_Back_Gray_Color;
    [self setData];
    [self UI];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - delegate


#pragma mark - event motheds

#pragma mark - private motheds

- (void)setData {
    
    _downViewHigh = 120;
    _topViewHgih = 200;
    _slideHigh = 50;
}

- (void)UI {
    
    //三个主层
    RoadDownV *downView = [[RoadDownV alloc] init];
    downView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:downView];
    
    RoadTopV *topView = [[RoadTopV alloc] init];
    topView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:topView];
    
    RoadSlideV *slideView = [[RoadSlideV alloc] init];
    slideView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:slideView];
    
    [self.view addSubview:self.chatV];
    
    __weak typeof(self) weakSelf = self;
    [downView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(-5);
        make.height.mas_equalTo(_downViewHigh);
    }];
    
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(_topViewHgih);
    }];
    
    [slideView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.equalTo(topView.mas_bottom);
        make.height.mas_equalTo(_slideHigh);
    }];
    
    [self.chatV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.equalTo(slideView.mas_bottom);
        make.bottom.equalTo(downView.mas_top).offset(-5);
        
    }];


    [downView addUI];
    [slideView addUI];
    [topView addUI];
    [self.chatV addUI];
    
    
    [downView addEvent:^(UIButton *btn) {
       
        UIBarButtonItem *backItem=[[UIBarButtonItem alloc]init];
        backItem.title=@"";
        weakSelf.navigationItem.backBarButtonItem = backItem;
        
        [weakSelf.navigationController pushViewController:[[RoadLineVC alloc] init] animated:YES];
        weakSelf.hidesBottomBarWhenPushed = NO;
        
    }];
}


#pragma mark - setters and getters

- (ChatV *)chatV {
    
    if (_chatV == nil) {
        
        _chatV = [[ChatV alloc] init];
    }
    return _chatV;
}

@end
